package com.mDigitalHealth.count;

import java.util.Calendar;

import com.mDigitalHealth.common.Utils;
import com.mDigitalHealth.thread.HourSaveThread;
import com.mDigitalHealth.thread.UploadThread;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.IntentSender.SendIntentException;
import android.preference.PreferenceManager;

public class AlarmReceiver extends BroadcastReceiver {
	public void onReceive(Context context, Intent intent) {
		System.out.println("***current time="+Utils.getFormatTime(System.currentTimeMillis()));
		String action = intent.getAction();
		System.out.println("**action="+action);
		SharedPreferences statePreference = context.getSharedPreferences("state", 0);
		SharedPreferences.Editor stateEditor = statePreference.edit();
		System.out.println("****preference steps="+statePreference.getInt("steps", 0));
		if(Utils.ALARM_MANAGER_SAVE_INFO.equalsIgnoreCase(action)){
			new HourSaveThread(context, statePreference, stateEditor, statePreference.getInt("steps", 0)).start();
		}else if(Utils.ALARM_MANAGER_UPLOAD_ACTION.equalsIgnoreCase(action)){
			new UploadThread(context, statePreference, stateEditor).start();
		}
	}
	
}
